<?
include("config.php");
session_start();
$promoid = $_REQUEST['promoid'];
$blink = new Blink;
$result = $blink->GetPromotion($promoid);

?>

<link rel="stylesheet" href="style.css" type="text/css">
<div id="header">
	<div id="menu">
		<ul>
			<li><a href="#" class="first">Homepage</a></li>
			<li class="current_page_item"><a href="#">My page</a></li>
			<li><a href="#">About Us</a></li>
			<li><a href="#">Contact Us</a></li>
		</ul>
	</div>
	<!-- end #menu -->
</div>
<!-- end #header -->
<div id="logo">
	<h1><a href="#">Bonus Link</a></h1>
	<p><em>Shop and get paid!</em></p>
</div>
<hr />
<!-- end #logo -->
<div id="page">
	<div id="page-bgtop">
		<div id="page-bgbtm">
			<div id="content">
				<div class="post">
					<div class="post-bgtop">
						<div class="post-bgbtm">
							<h2 class="title"><a href="#">Promotion Details</a></h2>
                                                        <p>
                                                            <span style="font-weight: bold; font-size:15px"><?=$result['title']?></span><BR>
                                                            <img src='uploads/pimage-<?=$result['promoid']?>.jpg' width=150 height=150 align=left><?=$result['description']?>
                                                            <BR>
                                                            <a href='r.php?u=<?=$_SESSION['id']?>&url=<?=urlencode($result['url'])?>&shopid=<?=$result['shopid']?>'>Click to get promotion</a>
                                                            
                                                        </p>
							
						</div>
					</div>
				</div>
				
				
			</div>
			<!-- end #content -->
			<div id="sidebar">
				<ul>
					<li>
						<h2>My Savings</h2>
						<ul>
                                                     <?

                                                    if(!$_SESSION['id']){
                                                        echo "<li>You're not logged in, please login <a href='login.php'>click here</a></li>";
                                                    }else{
                                                        echo "<li>welcome ".$_SESSION['user']."  <a href='logout.php'>Logout</a></li>";
                                                        //show him shop categories
                                                        //$tickets = $blink->GetUserTickets($_SESSION['id']);
                                                        //echo $tickets;
                                                        $trans  = $blink->GetUserTransactions($_SESSION['id'],"user","1");
                                                        $psaving = 0;
                                                        $asaving = 0;
                                                        
                                                        while (list($key,$value) = each($trans)){
                                                            if($value['save'] != 0){
                                                            if ($value['status'] == '0'){
                                                                $s = "<font color=yellow>Pending</font>";
                                                                $psaving += $value['save'];
                                                            }
                                                            if($value['status'] == '1'){
                                                                $s = "<font color=green>Approved</font>";
                                                                $asaving += $value['save'];
                                                            }
                                                            if($value['status'] == '2'){
                                                                 $s = "<font color=red>Rejected</font>";
                                                                $rsaving += $value['save'];
                                                            }
                                                            echo "<li>".$value['id']."  ".$value['shop']."  $".$value['save']."  ".$value['total']."  ".$s."</li>";
                                                            }
                                                        }
                                                        echo "<li>Your total approved saving: <font color=green>$".$asaving."</font><a href='claim.php' style='font-size:9px'>Claim now</a></li>";
                                                        echo "<li>Your total pending saving: <font color=yellow>$".$psaving."</font></li>";
                                                        echo "<li> Your total pending saving: <font color=red>$".$rsaving."</font></li>";
                                                       
                                                    }?>
						</ul>
					</li>
					<li>
						<h2>Shopping categories</h2>
						<ul>
														<?
                                                        $res = $blink->GetCategories();
                                                        if(is_array($res)){
                                                            while (list($key,$value) = each ($res)){
                                                             $ar = explode("|",$value);
                                                            echo "<li><a href='cat.php?catid=".$key."'>".$ar[0]."</a><BR> <span>Discount:".$ar[1]."%</span></li>";
                                                            }
                                                        }
                                                        ?>
						</ul>
					</li>
				</ul>
			</div>
			<!-- end #sidebar -->
		</div>
	</div>
</div>
<div id="footer">
	<p>Copyright (c) 2011 bonuslink. All rights reserved. </p>
</div>
<!-- end #footer -->
</body>
</html>

